PROGRAM MAPS
USE Extend_Texp
TYPE(DAMAP) Id, MAP, MAP2
REAL(DP) :: PREC = 1.D-10, xran
type(vecfield) F,F0,F1
INTEGER I

integer mf,me
mf=20
open(unit=mf,file='results.txt')
CALL INIT(NO1=4,ND1=2,NP1=0,NDPT1 =0)     !   <------------------ init for maps in ND1 degrees of freedom


call alloc(Id, MAP, MAP2)
call alloc(F,F1,F0);  
xran=22.d0  ! seed
! Produce a random vector field with no constant parts
do i=1,c_%nd2
 call TAYLOR_ran(F%V(I),1.D0,XRAN)
 F%V(I)=F%V(I) /10.D0
enddo


101 WRITE(6,*) "  "
WRITE(6,*) " CHOOSE TYPE OF GENERALIZED FACTORIZATION "
WRITE(6,*) " ONE EXPONENT = 0  DRAGT-FINN = 1  REVERSE DRAGT-FINN = -1  STOP PROGRAM = 2 "
READ(5,*) F%IFAC
WRITE(6,*) "  "

IF(F%IFAC==1) THEN
  F0=F.SUB.0
  F1=F.SUB.1
  F0%IFAC=0
  F1%IFAC=0
  ID=1
  MAP=TEXP(F,ID) 
  MAP=TEXP(F1,MAP) 
  MAP=TEXP(F0,MAP) 
ELSEIF(F%IFAC==-1) THEN
  F0=F.SUB.0
  F1=F.SUB.1
  F0%IFAC=0
  F1%IFAC=0
  ID=1
  MAP=TEXP(F0,ID) 
  MAP=TEXP(F1,MAP) 
  MAP=TEXP(F,MAP) 
ELSEIF(F%IFAC==0) THEN
 ID=1
 MAP=TEXP(F,ID) 
ELSE
 GOTO 100
ENDIF


CALL PRINT(MAP,MF,PREC)

ID=1
MAP2=TEXP(1.D0,F,ID) 

MAP2=MAP2-MAP


CALL PRINT(MAP2,MF,PREC)

xran=FULL_ABS(MAP2)

WRITE(6,*) "NORM OF  (EXTENDED TEXP) - (OLD TEXP) = ",XRAN


GOTO 101
100 CONTINUE

call kill(Id, MAP, MAP2)
call kill(F,F1,F0);  

close(mf);
END PROGRAM MAPS

